package com.ev.hr.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.ev.hr.dao.InterviewRecordDetailDao;
import com.ev.hr.domain.InterviewRecordDetailDO;
import com.ev.hr.service.InterviewRecordDetailService;
import com.ev.hr.vo.InterviewRecordDetailPageParam;
import com.ev.framework.utils.R;
import com.ev.apis.model.DsResultResponse;
import com.google.common.collect.Maps;


@Service
public class InterviewRecordDetailServiceImpl implements InterviewRecordDetailService {
	@Autowired
	private InterviewRecordDetailDao interviewRecordDetailDao;
	
	@Override
	public InterviewRecordDetailDO get(Long id){
		return interviewRecordDetailDao.get(id);
	}
	
	@Override
	public List<InterviewRecordDetailDO> list(Map<String, Object> map){
		return interviewRecordDetailDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return interviewRecordDetailDao.count(map);
	}
	
	@Override
	public int save(InterviewRecordDetailDO interviewRecordDetail){
		return interviewRecordDetailDao.save(interviewRecordDetail);
	}
	
	@Override
	public int update(InterviewRecordDetailDO interviewRecordDetail){
		return interviewRecordDetailDao.update(interviewRecordDetail);
	}

	@Override
	public int updateAll(InterviewRecordDetailDO interviewRecordDetail){
		return interviewRecordDetailDao.updateAll(interviewRecordDetail);
	}
	
	@Override
	public int remove(Long id){
		return interviewRecordDetailDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return interviewRecordDetailDao.batchRemove(ids);
	}

	@Override
	public R saveAndVerify(InterviewRecordDetailDO saveParam){
		if(saveParam.getId()!=null){
			return interviewRecordDetailDao.update(saveParam)>0?R.ok():R.error();
		}
		return interviewRecordDetailDao.save(saveParam)>0?R.ok():R.error();
	}

	@Override
	public Map<String, Object> getById(Long id) {
		InterviewRecordDetailDO interviewRecordDetail = interviewRecordDetailDao.get(id);
		if (interviewRecordDetail != null) {
			Map<String,Object> result = Maps.newHashMap();
			result.put("data",interviewRecordDetail);
			return R.ok(result);
		}
		return R.error();
	}

	@Override
	public Map<String, Object> pageList(InterviewRecordDetailPageParam pageParam) {
		Map<String,Object> result = Maps.newHashMap();
		List<Map<String, Object>> data = interviewRecordDetailDao.pageList(pageParam);
		int total = interviewRecordDetailDao.pageCount(pageParam);
		result.put("data", new DsResultResponse(pageParam.getPageno(),pageParam.getPagesize(),total,data));
		return R.ok(result);
	}

}
